package com.mpsc.spring.demo.controller;

import com.mpsc.spring.demo.job.ScheduleTask;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/job")
@Api(value = "JobController", tags = "定时任务管理")
public class JobController {

    private ScheduleTask scheduleTask;

    @Autowired
    public void TestController(ScheduleTask scheduleTask) {
        this.scheduleTask = scheduleTask;
    }

    @GetMapping("/updateCron")
    public String updateCron(String cron) {
        System.out.println("new cron :" + cron);
        scheduleTask.setCron(cron);
        return "ok";
    }

    @GetMapping("/updateTimer")
    public String updateTimer(Long timer) {
        System.out.println("new timer :" + timer);
        scheduleTask.setTimer(timer);
        return "ok";
    }

}
